﻿define(function (require) {
    require('models/project');
    var service = require('utility/service');

    window.WorkitemList = Backbone.Collection.extend({
        model: Workitem,
        comparator: function (e) {
            return e.get('Order');
        },
        initialize: function (model, args) {
            this.projectId = args.projectId;
        },
        projectId: null,
        getAll: function () {
            var _self = this;

            $.mobile.showPageLoadingMsg();

            service.GetWorkitems_Cache(function (workitems) {
                console.log(workitems.length);
                _self.add(workitems);
                _self.trigger("getAll");

                $.mobile.hidePageLoadingMsg();
            }, { status: null, projectId: _self.projectId, taskId: null, onlyMine: false, onlyMyAssign: false, isFinish: false })

        }
    });
});